package com.yanqu.road.server.cmd.activity.langyabang;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.LangYaBangProto;
import com.yanqu.road.server.cmd.CrossUnionCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.activity.langyabang.CrossLangYaBangMgr;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.utils.YanQuMessageUtils;

@Cmd(code = CrossProtocol.C_LANG_YA_GET_CAN_DECLARE_UNION_LIST,desc = "查看可以宣战的所有商会名" )
public class CrossLangYaBangGetCanDeclareWarUnionCmd extends CrossUnionCommand {
    private int activityId;
    private int pageNo;
    private int pageSize;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        LangYaBangProto.GetLangYaDeclareWarUnionListReq req = LangYaBangProto.GetLangYaDeclareWarUnionListReq.parseFrom(packet.getBytes());
        activityId = req.getActivityId();
        pageNo = req.getPageNo();
        pageSize = req.getPageSize();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        LangYaBangProto.GetLangYaDeclareWarUnionListResp.Builder resp = CrossLangYaBangMgr.getCanDeclareWarUnionAndRank(activityId, groupId, packet.getPlayerId(),pageNo,pageSize);
        YanQuMessage pbMsg = YanQuMessageUtils.buildMessage(ClientProtocol.U_LANG_YA_GET_DECLARE_UNION_LIST,resp);
        MessageHelper.sendPacket(serverId,packet.getPlayerId(),pbMsg);
    }

    @Override
    public void sendData() {

    }
}
